﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddPatient.aspx.cs" Inherits="Page_Customer_AddPatient" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no" />
    <title>新增就诊人</title>

    <link href="../../Content/syzyy/css/reset.css" rel="stylesheet" />
    <link href="../../Content/syzyy/css/ylt_common.css" rel="stylesheet" />
    <link href="../../layui/css/layui.css" rel="stylesheet" />

    <script src="../../Scripts/jquery-1.8.0.min.js"></script>
    <script src="../../Scripts/jquery.form.js"></script>
    <%--layui--%>
    <script src="../../layui/layui.js"></script>
    <script src="../../Content/syzyy/js/additional-methods.js"></script>
    <style type="text/css">
        body {
            background-color: #fff;
        }

        .btn-white {
            display: inline-block;
            background-color: #fff;
            color: #78b830;
            border: 1px solid #78b830;
            border-radius: .078rem;
            width: 100%;
            line-height: 4.05rem;
            font-size: 3.4rem;
            border-radius: 3px;
        }
    </style>
</head>
<body>
    <form class="layui-form" id="AddForm" name="patient_add_form" action="" enctype="multipart/form-data" method="post">
        <ul class="xz_jzr">
            <li class="">
                <i class="f_red">*</i>
                <img class="xz_icon xz_blur" src="../../Content/syzyy/img/icon_xingming2@2x.png" />
                <img class="xz_icon xz_focus" style="display: none;" src="../../Content/syzyy/img/icon_xingming@2x.png" />
                <!--<span class="xz_tit">姓名:</span>-->
                <input type="text" class="xz_vl" name="realName" id="jzr_name" value="" placeholder="请填写就诊人姓名" />
            </li>

            <li class="">
                <i class="f_red">*</i>
                <img class="xz_icon xz_blur" src="../../Content/syzyy/img/icon_shenfenzheng2@2x.png" />
                <img class="xz_icon xz_focus" style="display: none;" src="../../Content/syzyy/img/icon_shenfenzheng@2x.png" />
                <!--<span class="xz_tit">身份证号</span>-->
                <input type="text" class="xz_vl" name="idCard" id="jzr_id" value="" placeholder="请填写就诊人身份证号" />
            </li>
            <li class="">

                <i class="f_red">*</i>

                <img class="xz_icon xz_blur" src="../../Content/syzyy/img/icon_jiuzhenka2@2x.png" />
                <img class="xz_icon xz_focus" style="display: none;" src="../../Content/syzyy/img/icon_jiuzhenka@2x.png" />
                <input type="text" class="xz_vl" name="patientCard" id="jzr_card" value="" placeholder="请填写就诊人卡号" />
            </li>

            <li class="">
                <i class="f_red">*</i>
                <img class="xz_icon xz_blur" src="../../Content/syzyy/img/icon_shoujihao2@2x.png" />
                <img class="xz_icon xz_focus" style="display: none;" src="../../Content/syzyy/img/icon_shoujihao@2x.png" />
                <!--<span class="xz_tit">手机号</span>-->
                <input type="text" class="xz_vl" name="phone" id="jzr_phone" value="" placeholder="请填写就诊人手机号" />
            </li>
        </ul>
        <p class="mr_tips">
            请您填写真实信息，以免影响您就诊
        </p>
        <div class="xz_bth">
            <button id="add_jzr" class="u-btn u-btn-green u-btn-lg" lay-submit="" lay-filter="formDemo">添加就诊人</button>
        </div>

        <div class="mr_tips">
            <div class="fs-24px fc-red-orange patient-add-text" style="color: #f3831a;">若没有就诊卡号？</div>
            <div class="fs-22px fc-666 patient-add-text-box">
                您再也不用担心啦，医院已提供<i style="color: green;">在线建卡</i>功能，
            建卡后提供虚拟就诊卡号，您照样轻松预约挂号。首次就诊即可凭身份证领取实体卡哦~
            </div>
        </div>

        <div class="xz_bth">
            <a href="CreateCard.aspx"><button type="button" class="btn-white" >在线建卡</button></a>
        </div>
    </form>
    <div id="errormsgs" class="errormsgs"
        style="padding: 10px; color: red; font-weight: bold; display: none;">
        &nbsp;
    </div>
    ﻿
</body>

<script type="text/javascript">
    $('.xz_vl').each(function (i, e) {
        $(e).blur(function () {
            $(this).siblings('.xz_focus').hide();
            $(this).siblings('.xz_blur').show();
        });
        $(e).focus(function () {
            $(this).siblings('.xz_focus').show();
            $(this).siblings('.xz_blur').hide();
        });
    });

    function ShowRequest(data) {
        if (data.status == "1") {
            layer.msg(data.info, {
                time: 1000 //2秒关闭（如果不配置，默认是3秒）
            }, function () {
                window.location.href = "AllPatient.aspx";
            });
        }
        else {
            layer.msg(data.info, {
                time: 1000 //2秒关闭（如果不配置，默认是3秒）
            }, function () {
                $("#add_jzr").text("保存");
                $("#add_jzr").css({ 'background-color': '#78B830' });
                $("#add_jzr").attr('disabled', false);
            });
        }
    }

    //Demo
    layui.use('form', function () {
        var form = layui.form();
        //监听提交
        form.on('submit(formDemo)', function (data) {
            var option = {
                dataType: 'json',
                url: '/Handler/SyzyyHandler.ashx?Action=AddPatientInfo&openid=' + '<%=openid %>' + "&type=add",
                beforeSubmit: function (a) {
                    var flag = 'true';
                    if ($('#jzr_name').val() == '') {
                        msg = '请填写就诊人姓名!';
                        flag = false;
                    } else if ($('#jzr_id').val() == '') {
                        msg = '请填写就诊人身份证号!';
                        flag = false;
                    } else if (!isIdCardNo($('#jzr_id').val())) {
                        flag = false;
                        msg = '身份证号格式不正确';
                    } else if ($('#jzr_card').val() == '') {
                        msg = '请填写就诊人就诊卡!';
                        flag = false;
                    } else if (!((/^(0|86|17951)?(13[0-9]|14[579]|15[012356789]|17[01235678]|18[0-9]|14[579])[0-9]{8}$/)
                        .test($.trim($('#jzr_phone').val())))) {
                        flag = false;
                        msg = '请填写有效的手机号';
                    }
                    if (!flag) {
                        layer.msg(msg, {
                            time: 1000 //2秒关闭（如果不配置，默认是3秒）
                        });
                    };
                    if (flag) {
                        $("#add_jzr").text("保存中");
                        $("#add_jzr").css({ 'background-color': 'grey' });
                        $("#add_jzr").attr('disabled', true);
                    }
                    return flag;
                },
                success: ShowRequest
            };
            $('#AddForm').ajaxForm(option);
        });
    });
</script>
</html>
